package com.qianyi.person.service;

import com.auth0.jwt.JWT;
import com.auth0.jwt.algorithms.Algorithm;
import com.qianyi.person.domain.User;
import org.springframework.stereotype.Service;

import java.util.Date;

/**
 *@author tonypy
 * 2018/9/20
 * jwt token
 * */
@Service
public class TokenService {

   public String getToken(User user){
       String token="";
       token= JWT.create().withAudience(user.getId().toString())
               .withExpiresAt(new Date(System.currentTimeMillis()+60*1000)).sign(Algorithm.HMAC256(user.getPassword()));
       return token;
   }
   public static void main(String args[]){
       System.out.println(new Date(System.currentTimeMillis()+60*1000));
   }
}
